import feedparser
import os
import Models
import time
import Gastics_Main
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
from google.appengine.api import users
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from datetime import datetime

def ParseRSS2GData():
    user = users.User("Zhao.Zhongming@gmail.com")
    d = feedparser.parse("http://www.zuosa.com/rss/user/zhongmin")
    items =  d.entries
    for item in items: 
        if item.title.startswith("+"):
            dataList = item.title[1:].split()
            date = item.updated
            if dataList.count > 0:
                currentkilo = dataList[0]
                print currentkilo
                if dataList.count > 1:
                    percost = dataList[1]
                else:
                    percost = GetLastCost(user)
                print percost
                
                if dataList.count > 2:    
                    price = dataList[2]
                else:
                    price = GetLastPrice(user)
                print price 
                

            
    
if __name__ == "__main__":
    ParseRSS2GData()
